package group.newsReader.Mapper;

import group.newsReader.Pojo.History;
import group.newsReader.Pojo.News;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NewsMapper {
    @Select("select * from news")
    List<News>recommend();
    @Select("select * from news where news_id=#{id}")
    News news(int id);
    @Insert("insert into news (title, content, publish_time, source, cefr_level, category)" +
            " values (news.title,news.content,news.publish_time,news.source,news.cefr_level,news.category)")
    String insertNews(News news);
    @Select("select * from history")
    List<History>history();
    @Insert("insert into history (news_id, title, read_time) values (#{id}, #{title}, #{formattedTime})")
    void addHistory(int id, String title, String formattedTime);
    @Delete("delete from history where news_id=#{id}")
    void deleteHistory(int id);
    @Insert("insert into news (title, content, publish_time, source, cefr_level, category, is_hot,feature_vector)" +
            "values (#{title},#{content},#{date},#{origin},#{level},#{type},#{is_hot},#{vector})")
    void saveNews(String title, String content, String date, String type,String origin,String level,boolean is_hot,String vector);
    @Select("select * from news where news_id%10 = 0 ")
    List<News> getNews();
}
